package homework.test3;

import java.util.TreeMap;
import java.util.TreeSet;

/*
需求：创建一个TreeMap集合，键是学生对象(Student)，值是籍贯(String)。

学生属性姓名和年龄，按照年龄进行排序并遍历。

 */
public class Demo3 {
    public static void main(String[] args) {
        TreeMap<Student,String> tm = new TreeMap<>();

        Student stu1 = new Student("张三",23);
        Student stu2 = new Student("李四",22);
        Student stu3 = new Student("王五",34);
        Student stu4 = new Student("赵六",23);

        tm.put(stu1,"合肥");
        tm.put(stu2,"南京");
        tm.put(stu3,"杭州");
        tm.put(stu4,"成都");

        tm.forEach((key,value)-> System.out.println(key+"..."+value));
    }
}
